<ui:composition template="/WEB-INF/template/popup.xhtml"
                xmlns="http://www.w3.org/1999/xhtml"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:c="http://java.sun.com/jsp/jstl/core"
                xmlns:fn="http://java.sun.com/jsp/jstl/functions"
                xmlns:a4j="http://richfaces.org/a4j"
                xmlns:rich="http://richfaces.org/rich"
                xmlns:sgbd="http://java.sun.com/jsf/composite/components">

    <ui:define name="header">
        <h:outputText value="Se connecter à la base de données #{compteBean.current.name} (#{compteBean.current.typeBDDid.typeBDD})" />
    </ui:define>
    <ui:define name="form">
        <h:panelGrid columns="3" rendered="#{compteBean.current.typeBDDid.typeBDD == 'MySQL'}">
            <h:outputText value="Login " />
            <h:inputText value="#{mySqlConnect.login}" 
                         required="true"
                         id="loginConnectionMySql"
                         requiredMessage="Veuillez renseigner le login" />
            <rich:message id="loginConnectionMySqlMsg" for="loginConnectionMySql" />
            
            <h:outputText value="Password " />
            <h:inputSecret value="#{mySqlConnect.password}" 
                           required="true"
                           id="passwordConnectionMySql"
                           requiredMessage="Veuillez renseigner le mot de passe" />
            <rich:message id="passwordConnectionMySqlMsg" for="passwordConnectionMySql" />
            
            <h:outputText value="Rôle de connexion " />
            <rich:select id="roleDeConnexionMySql" 
                         value="#{mySqlConnect.roleDeConnexion}"
                         required="true" 
                         requiredMessage="Veuillez renseigner le rôle de connexion">
                <f:selectItem itemLabel="Developpeur" itemValue="Developpeur" />
                <f:selectItem itemLabel="Administrateur" itemValue="Administrateur" />
            </rich:select>
            <rich:message id="roleDeConnexionMySqlMsg" for="roleDeConnexionMySql" />
            
        </h:panelGrid>
        <h:panelGrid columns="2" rendered="#{compteBean.current.typeBDDid.typeBDD == 'MySQL'}">
            <a4j:commandButton value="Se connecter"
                               action="#{mySqlConnect.connect()}"
                               execute="connectPopup"
                               oncomplete="if (#{facesContext.maximumSeverity==null}) {#{rich:component('connectPopup')}.hide();}" >

            </a4j:commandButton>
            <a4j:commandButton value="Cancel"
                               execute="@this"
                               oncomplete="#{rich:component('connectPopup')}.hide(); return false;" />
        </h:panelGrid>
        
        <h:panelGrid columns="3" rendered="#{compteBean.current.typeBDDid.typeBDD == 'Oracle'}">
            <h:outputText value="Login " />
            <h:inputText value="#{oracleConnect.login}" 
                         required="true"
                         id="loginConnectionOracle"
                         requiredMessage="Veuillez renseigner le login" />
            <rich:message id="loginConnectionOracleMsg" for="loginConnectionOracle" />
            
            <h:outputText value="Password " />
            <h:inputSecret value="#{oracleConnect.password}" 
                           required="true"
                           id="passwordConnectionOracle"
                           requiredMessage="Veuillez renseigner le mot de passe" />
            <rich:message id="passwordConnectionOracleMsg" for="passwordConnectionOracle" />
            
            <h:outputText value="Rôle de connexion " />
            <rich:select id="roleDeConnexionOracle" 
                         value="#{oracleConnect.roleDeConnexion}"
                         required="true" 
                         requiredMessage="Veuillez renseigner le rôle de connexion">
                <f:selectItem itemLabel="Developpeur" itemValue="Developpeur" />
                <f:selectItem itemLabel="Administrateur" itemValue="Administrateur" />
            </rich:select>
            <rich:message id="roleDeConnexionOracleMsg" for="roleDeConnexionOracle" />
            
        </h:panelGrid>
        <h:panelGrid columns="2" rendered="#{compteBean.current.typeBDDid.typeBDD == 'Oracle'}">            
            <a4j:commandButton value="Se connecter"
                               action="#{oracleConnect.connect()}"                               
                               execute="connectPopup"
                               oncomplete="if (#{facesContext.maximumSeverity==null}) {#{rich:component('connectPopup')}.hide();}" >

            </a4j:commandButton>

            
            <a4j:commandButton value="Cancel"
                               execute="@this"
                               oncomplete="#{rich:component('connectPopup')}.hide(); return false;" />
        </h:panelGrid>
        
    </ui:define>
</ui:composition>